package work;

/**
 * @TODO
 * @Author xu
 * 2025/2/24
 */
public class Day4_6 {
    public static void main(String[] args) {
        int[] array = {5, 11, 15, 24, 36, 47, 59, 66};
        System.out.println("原数组:");
        printArray(array);
        reverseArray(array);
        System.out.println("交换后的数组:");
        printArray(array);
    }
    public static void reverseArray(int[] array) {
        int left = 0;
        int right = array.length - 1;

        while (left < right) {
            int temp = array[left];
            array[left] = array[right];
            array[right] = temp;

            left++;
            right--;
        }
    }

    public static void printArray(int[] array) {
        for (int num : array) {
            System.out.print(num + " ");
        }
        System.out.println();
    }

}
